package com.jcp.service.imple;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jcp.dao.phoneMapper;
import com.jcp.entity.Record;
import com.jcp.service.phoneService;
import com.jcp.util.LayuiData;

import tk.mybatis.mapper.entity.Example;

/**
 * 手机端的进出记录的手机服务层实现类
 * @author 朱耿封
 *
 */
@Service
public class phoneServiceImple implements phoneService {
	
	@Autowired
	private phoneMapper pm;

	/**
	 * 手机端的车辆进出的行车记录
	 * @param page：第几页开始
	 * @param limit：每页几条记录
	 * @param strLike：时间模糊
	 * @return
	 */
	@Override
	public LayuiData<Record> selectRecordByPage(int page, int limit, String strLike) {
		//开启分页方法
		PageHelper.startPage(page, limit);
		//创建Example对象
		Example ex = new Example(Record.class);
		//进行模糊查询的集合
		ex.createCriteria().andLike("carNumber", strLike+"%");
		//获取集合
		List<Record> list = pm.selectByExample(ex);
		//创建PageInfo对象
		PageInfo<Record> pageInfo=new PageInfo<Record>(list);
		//将数据存储进LayuiData这个类中
		LayuiData<Record> ld = new LayuiData<>(0, "", (int)pageInfo.getTotal(), pageInfo.getList());
		return ld;
	}

}
